<?php

declare(strict_types=1);
namespace Service\MonitorService;

use Service\BaseService;
use Service\HttpServer\Http;
use App\Model\PssModel\Sysconfig;

/**
 * 异常通知
 * @author chenshubo
 */
class MonitorService extends BaseService
{
    protected $url = 'https://oapi.dingtalk.com/robot/send?access_token=d7b0da132c919d54b386eaeb4cc3792b631c30c70a189c5f716cef2ec4597988';
    /**
     * 发送系统异常
     * @param string $contents
     */
    public function sendMsg(string $contents)
    {
        $config = Sysconfig::instance()->getConfigByEventsValue('sysconfig');
        $source = $config['AppName'] ??"";
        $AppName = $source.'BBC搜索服务';
        $message="【云仓异常消息提醒】【{$AppName}】{$contents}";
        $data = [
            'msgtype' => 'text',
            'text' => [
                'content' => $message
            ]
        ];
        Http::postJsonCurl($this->url, $data);
    }
}